Ext.define('AmpleHarvest.objects.metrics.sitesRollup.postList',
{
	extend			: 'Ext.grid.Panel',
	alias			: 'widget.ampleharvest-objects-metrics-sitesrollup-postlist',
	anchor			: '100% 100%',
	layout			: 'fit',
	uses			: [
	    			   'Ext.ux.PreviewPlugin',
	    			   'AmpleHarvest.objects.metrics.util.cMetricsUtils'
	    			   ],
	store			: Ext.create('AmpleHarvest.DATA.Store.cSiteMetricsDirect'),
	viewConfig: {
        id: 'gv', // ID is reset to dynamic in initComponent
        trackOver: false,
        stripeRows: false,
        plugins: [{
            ptype: 'preview',
            bodyField: 'content',
            expanded: true,
            pluginId: 'preview'
        }]
    },
	columns			: [
	       			   { header : 'Title', dataIndex : 'title', flex : 6, tips: { msg : 'test'} },
	       			   { header : 'Post Number', dataIndex : 'postNumber', flex : 1 },
	       			   { header : 'Date Posted', dataIndex : 'postDate', flex : 2 },
	       			   { header : 'Author', dataIndex : 'author', flex : 1 }
	       			   ],    	
	       			   
//	bbar			: Ext.create('Ext.PagingToolbar', 
//						{
//					        store: this.store,
//					        displayInfo: true,
//					        displayMsg: 'Displaying topics {0} - {1} of {2}',
//					        emptyMsg: "No topics to display",
//					        items:[
//					            '-', 
//					            {
//					                text: 'Show Preview',
//					                pressed: true,
//					                enableToggle: true,
//					                toggleHandler: function(btn, pressed) 
//					                {
//					                    var preview = Ext.getCmp('gv').getPlugin('preview');
//					                    preview.toggleExpanded(pressed);
//					                }
//					            }]
//						}),
	initComponent	: function()
	{
		this.util_metrics = Ext.create('AmpleHarvest.objects.metrics.util.cMetricsUtils');
		
		this.viewConfig.id = 'gv'+(((1+Math.random())*0x10000)|0).toString(16).substring(1);
		
		var pluginExpanded = true;
		
    	this.dockedItems = [
		                	   {
		                		   	xtype		: 'pagingtoolbar',
		  							store		: this.getStore(),
		                	   		dock		: 'bottom',
		                	   		uuid		: this.viewConfig.id,
		                	   		displayInfo	: true,
		                	   		items:[
		                	                '-', {
		                	                text: 'Show Preview',
		                	                pressed: pluginExpanded,
		                	                enableToggle: true,
		                	                toggleHandler: function(btn, pressed) {	                	                	
		                	                    var preview = Ext.getCmp(this.ownerCt.uuid).getPlugin('preview');
		                	                    preview.toggleExpanded(pressed);
		                	                }
		                	            }]
		                	   }];
		
		this.itemsPerPage = 20;
		
		var obj_extraParams = {
//				start		: 0,
				limit		: this.itemsPerPage
		}
		
		if(this.str_directPath)
		{
//			console.log('strip');
//			console.log(this.str_directPath);
			this.getStore().getProxy().url = this.str_directPath;//this.util_metrics.stripServer(this.str_directPath);
		}
		
		this.callParent();
		
		if(Ext.isArray(this.obj_data))
		{
			this.getStore().set_ExtraParams();
			this.getStore().loadRawData(this.obj_data);
			this.AHcaller.add(this);
		}
		else
		{
			this.getStore().set_ExtraParams(obj_extraParams);
			this.getStore().load();
		}
	}
});